home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / a86a.arc / EXCLUSIV.DOC < prev    next >
Encoding:
Text File  |  1986-06-22  |  7.1 KB  |  156 lines

  1. ---EXCLUSIV.DOC---
  2.  
  3. Some Features Unique to A86
  4.  
  5.  
  6. The IF Statement
  7.  
  8. As a "nudge" in the direction of structured programming, A86 offers the IF
  9. statement.  Suppose you want to conditionally skip around just one instruction.
  10. Ordinarily, this would require, for example:
  11.  
  12.   JNZ >L1           ; skip the following move if NZ
  13.   MOV AX,BX         ; make this move only if Z
  14. L1:                 ; this label exists only for the above instruction-skip
  15.  
  16. You may replace the above code with the single line:
  17.  
  18.   IF Z MOV AX,BX
  19.  
  20. The above line generates exactly the same code as the previous 3 lines-- a
  21. conditional jump of the opposite condition, around the statement given in the
  22. tail of the IF statement.
  23.  
  24. You may use any condition that would follow the "J" in a conditional jump
  25. instruction, except CXZ, which does not have a reverse condition.  The assembler
  26. interprets the condition by appending a "J" to the beginning of the condition;
  27. so that the symbols "C", "NC", "Z", "NZ", etc. are not reserved by the
  28. assembler, and can be used-defined in other contexts.
  29.  
  30.  
  31. Multiple operands to PUSH, POP, INC, DEC
  32.  
  33. A86 will accept any number of register operands for the instructions PUSH, POP,
  34. INC, and DEC; it will generate the appropriate machine instruction for each
  35. operand.  For example, the statement PUSH AX,BX is the same as the two
  36. statements PUSH AX and PUSH BX.
  37.  
  38. A numeric operand appearing in an INC or DEC statement will cause the previous
  39. INC(s) or DEC(s) to be propagated that number of times.  For example, the
  40. statement INC AX,4 will generate 4 INC AX instructions.  The statement
  41. DEC AL,BX,2 will generate DEC AL, DEC BX, DEC AL, DEC BX.
  42.  
  43.  
  44. Conditional Return Instructions
  45.  
  46. Programmers accustomed to the conditional-return instructions of the 8080/Z80
  47. will appreciate the following feature: A86 allows the operand to a conditional
  48. jump instruction to be one of the three RET instructions RET, RETF, or IRET.
  49. The assembler will find a nearby return-instruction of the indicated flavor,
  50. and use that as the target for the conditional jump.  For example, JZ RET
  51. is the replacement for the 8080's RZ return-if-zero instruction.
  52.  
  53. In other 8086 assembly languages, you have to find the nearby instruction
  54. yourself, attach a label to it, and use that label.  Note that it does not
  55. suffice to attach a label to a single RET instruction and use that label
  56. throughout the program: the range of conditional jumps is only 128 bytes in
  57. either direction.
  58.  
  59. What happens if A86 does not find a nearby return instruction?  In that case,
  60. A86 issues an error, "02 Jump > 128", for the next matching return-instruction
  61. in the program.  If there is no subsequent reutrn-instruction, the return-
  62. mnemonic will appear as an undefined symbol at the end of the program.   In
  63. either case, you correct the problem by inserting a free-standing return-
  64. instruction at some nearby point in the program, where it will not affect
  65. the existing code (typically following an unconditional JMP instruction).
  66. If there is no good place to insert a return-instruction, you can always
  67. replace the "Jcond RET" with an "IF cond RET".
  68.  
  69.  
  70. A86 extensions to the MOV instruction
  71.  
  72. There are a number of MOV instructions available in A86 that are not a part of
  73. the machine instruction set.
  74.  
  75. First, moves between segment registers are allowed.  For example, if you code
  76. MOV ES,DS  , the assembler will generate a PUSH DS followed by a POP ES; which
  77. will effect the move that you intended.
  78.  
  79. Second, MOV allows 3 operands.  A statement MOV x,y,z is equivalent to the two
  80. statements MOV y,z followed by MOV x,y.
  81.  
  82.  
  83. Local Labels
  84.  
  85. If you examine most assembly-language program symbol tables, you will find that
  86. the symbols can be partitioned into two levels of significance.   About half the
  87. symbols are the names of procedures and variables having global significance.
  88. If the names of these symbols are chosen intelligently and carefully, the
  89. program's readability improves drastically. (They usually aren't chosen well,
  90. most often because the assembler restricts symbols to 6 letters, or becuase
  91. the programmer's habits are influenced by such assemblers.)
  92.  
  93. The other half of the symbols in a program have a much lower, local
  94. significance.  They are only place-markers used to implement small loops and
  95. local branching (e.g., "skip the next 2 intructions if the Z-flag is set").
  96. Assigning full-blown names to these labels reduces the readability of your
  97. program in two ways:  First, it is harder to recognize local jumps for what they
  98. are-- they are usually the assembly-language equivalent of high-level language
  99. constructs like IF statements and WHILE-loops.  Second, it is harder to follow
  100. the global, significant symbols because they are buried in a sea of the
  101. place-marker symbols in the symbol table.
  102.  
  103. A86 solves this problem with local symbols.  If a symbol in your program
  104. consists of a single letter followed by one or more decimal digits (L3, X123,
  105. Y37, etc.), then the symbol is a local symbol.  Local symbols do not appear in
  106. the A86 XREF cross-reference listing. They can also be redefined to something
  107. completely different later in the program.
  108.  
  109. Because local labels can be redefined, you must take care to specify which one
  110. you are referring to in your program.  If your reference is a forward-reference
  111. (the label occurs further down in the program from the reference), then the
  112. reference must be preceeded by a ">".  For example,
  113.  
  114. L2:
  115.   MOVSB
  116.   INC BX
  117.   LOOP L2        ; lack of ">" means L2 is above this statement
  118.   .
  119.   .
  120.   JNZ >L2        ; ">" indicates L2 is below this statement
  121.   .
  122.   .
  123. L2:
  124.  
  125. I recommend that you assign all your local labels the names L0 through L9.  If
  126. your program is so complex that it needs more than 10 place-holders in any one
  127. stretch of code, then that stretch needs to be rewritten.
  128.  
  129.  
  130.  
  131. Operands to AAM and AAD Instructions
  132.  
  133. Those of you who have examined 86-family opcodes with an eagle-eye will have
  134. noticed a somewhat spurious "0A" opcode generated after every AAM or AAD
  135. instruction.  The opcode is there to provide the constant divisor or
  136. multiplicand for the instruction.  Believe it or not, there wasn't enough room
  137. in the microcode of the original 8086 to hold this constant!  Although Intel
  138. has never announced the generality of AAM and AAD, it is there: you can
  139. substitute any other constant for 0A (decimal 10), and that constant will be
  140. used.  A86 supports this by letting you give a constant byte-sized operand to
  141. AAM or AAD.  Particularly useful are the instructions AAM 16, which unpacks AL
  142. into nibbles AH and AL; and AAD 16, which reverses the process, packing nibbles
  143. AH and AL into AL.
  144.  
  145.  
  146. Single-Operand Forms of the TEST Instruction
  147.  
  148. A86 allows the TEST instruction to have a single operand, to set the flags
  149. according to the value of the operand.  If the operand is a register, A86
  150. generates a TEST of the register with itself.  If the operand is a memory
  151. quantity, A86 generates a TEST of the memory with the constant -1 (i.e., the
  152. quantity will be ANDed with an all 1's constant).  For example, instead of
  153. TEST DL,DL, you can code simply TEST DL.  Instead of TEST WVAR,0FFFF, you can
  154. code simply TEST WVAR.
  155.  
  156.